package com.kurumi.query;

import java.util.Date;

import org.springframework.format.annotation.DateTimeFormat;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.kurumi.util.StringUtil;

public class UploadScanQuery extends PageQuery{

	private String folderName;
	
	@DateTimeFormat(pattern="yyyy-MM-dd")
	private Date uploadStartDate;
	
	
	@DateTimeFormat(pattern="yyyy-MM-dd")
	private Date uploadEndDate;
	
	private String isRelevance;
	
	// 查询结果集
	private Object datas;

	public String getFolderName() {
		return StringUtil.empty(folderName);
	}

	public void setFolderName(String folderName) {
		this.folderName = folderName;
	}

	public Date getUploadStartDate() {
		return uploadStartDate;
	}

	public void setUploadStartDate(Date uploadStartDate) {
		this.uploadStartDate = uploadStartDate;
	}

	public Date getUploadEndDate() {
		return uploadEndDate;
	}

	public void setUploadEndDate(Date uploadEndDate) {
		this.uploadEndDate = uploadEndDate;
	}

	public String getIsRelevance() {
		return StringUtil.empty(isRelevance);
	}

	public void setIsRelevance(String isRelevance) {
		this.isRelevance = isRelevance;
	}
	
	
	
	public Object getDatas() {
		return datas;
	}

	public void setDatas(Object datas) {
		this.datas = datas;
	}

	@JsonIgnore
	public boolean isEmpty() {
		dealDate();
		if (this.getUploadStartDate() == null&& this.getUploadEndDate() == null
				&& this.getFolderName() == null && this.getIsRelevance() == null) {
			return true;
		}
		return false;
	}
	
	private void dealDate() {
		if (this.getUploadStartDate() == null && this.getUploadEndDate() != null) {
			this.setUploadStartDate(this.getUploadEndDate());
		} else if (this.getUploadStartDate() != null && this.getUploadEndDate() == null) {
			this.setUploadEndDate(this.getUploadStartDate());
		}

	}
}
